function Button () {
	// ====================================================================================================================
	// NOTE:
	// Because we target on phone, I'll remove the mouse over state. (Normally, the button will glow when we mouse over it)
	// ====================================================================================================================
	
	// Image
	this.m_image = 0;
	this.m_sxUp = 0;     // Source x of the up image
	this.m_syUp = 0;     // Source y of the up image
	this.m_sxDown = 0;   // Source x of the down image
	this.m_syDown = 0;   // Source y of the down image
	this.m_sw = 0;       // Source width of both state image (they should be the same anyway)
	this.m_sh = 0;       // Source height of both state image (they should be the same anyway)
	
	// Draw destination coordination
	this.m_dx = 0;
	this.m_dy = 0;
	this.m_dw = 0;
	this.m_dh = 0;
	
	// Touch rect (We have to distinct these param, because some button image will different with their touch RECT, 
	// for example: A button with glow out side. We don't click on the glow part)
	this.m_tx = 0;
	this.m_ty = 0;
	this.m_tw = 0;
	this.m_th = 0;
	
	// Caption of the button
	this.m_caption = "";
	this.m_cx = 0;
	this.m_cy = 0;
	this.m_font = "Verdana";
	this.m_fontSize = 20;
	this.m_cRed = 255;
	this.m_cGreen = 255; 
	this.m_cBlue = 255;
	
	// Function that will be call when button is clicked
	this.m_function = null;
	
	// Status
	var isInTheMiddleOfAClick = 0;
	var isClicked = 0; // 0 = Up. 1 = Down.
	
	
	// Load and image, and set source param for the button
	this.LoadImage = function(path, sxu, syu, sxd, syd, sw, sh) {
		this.m_image = g_graphicEngine.LoadImage(path);
		this.m_sxUp = sxu;
		this.m_syUp = syu;
		this.m_sxDown = sxd;
		this.m_syDown = syd;
		this.m_sw = sw;
		this.m_sh = sh;
	}
	
	// Set position, and also the touch rect if you like.
	this.SetPosition = function (x, y, w, h, tx, ty, tw, th) {
		this.m_dx = x;
		this.m_dy = y;
		
		if (w == null) this.m_dw = this.m_sw;
		else           this.m_dw = w;
		if (h == null) this.m_dh = this.m_sh;
		else           this.m_dh = h;
		
		if (tx == null) this.m_tx = this.m_dx;
		else            this.m_tx = tx;
		if (ty == null) this.m_ty = this.m_dy;
		else            this.m_ty = ty;
		if (tw == null) this.m_tw = this.m_dw;
		else            this.m_tw = tw;
		if (th == null) this.m_th = this.m_dh;
		else            this.m_th = th;
		
		this.m_cx = this.m_tx + this.m_tw * 0.5;
		this.m_cy = this.m_ty + this.m_th * 0.5;
	}
	
	// Set the touch rect
	this.SetTouchRect = function (x, y, w, h) {
		this.m_tx = x;
		this.m_ty = y;
		this.m_tw = w;
		this.m_th = h;
	}
	
	// Register the function
	this.RegisterFunction = function (func) {
		this.m_function = func;
	}
	
	// Set caption
	this.SetCaption = function (caption, x, y, font, size, r, g, b) {
		this.m_caption = caption;
		if (x != null) this.m_cx = x;
		if (y != null) this.m_cy = y;
		if (font != null) this.m_font = font;
		if (size != null) this.m_fontSize = size;
		if (r != null) this.m_cRed = r;
		if (g != null) this.m_cGreen = g;
		if (b != null) this.m_cBlue = b;
	}
	
	
	this.Draw = function() {
		if (isClicked == 0) {
			g_graphicEngine.Draw (g_context, this.m_image, this.m_sxUp, this.m_syUp, this.m_sw, this.m_sh, this.m_dx, this.m_dy, this.m_dw, this.m_dh);
			//console.log (this.m_sxUp + " / " + this.m_syUp + " / " + this.m_sw + " / " + this.m_sh);
			//console.log (this.m_dx + " / " + this.m_dy + " / " + this.m_dw + " / " + this.m_dh);
		}
		else {
			g_graphicEngine.Draw (g_context, this.m_image, this.m_sxDown, this.m_syDown, this.m_sw, this.m_sh, this.m_dx, this.m_dy, this.m_dw, this.m_dh);
		}
		
		g_graphicEngine.DrawTextRGB (g_context, this.m_caption, this.m_cx, this.m_cy, this.m_tw, this.m_font, this.m_fontSize, true, false, "center", this.m_cRed, this.m_cGreen, this.m_cBlue, 1);
	}
	
	this.OnMouseMove = function (x, y) {
		if (x >= this.m_tx && x <= this.m_tx + this.m_tw
		&&  y >= this.m_ty && y <= this.m_ty + this.m_th) {
			isClicked = isInTheMiddleOfAClick;
			return 1;
		}
		else {
			// If move outside the button, surely isClick will be 0
			isClicked = 0;
			return 0;
		}
	}
	
	this.OnMouseDown = function (x, y) {
		//console.log (x + " / " + y);
		//console.log (this.m_tx + " / " + this.m_ty + " / " + this.m_tw + " / " + this.m_th);
		if (x >= this.m_tx && x <= this.m_tx + this.m_tw
		&&  y >= this.m_ty && y <= this.m_ty + this.m_th) {
			isClicked = 1;
			isInTheMiddleOfAClick = 1;
		}
		else {
			isClicked = 0;
			isInTheMiddleOfAClick = 0;
		}
		return isClicked;
	}
	
	this.OnMouseUp = function (x, y) {
		isClicked = 0;
		isInTheMiddleOfAClick = 0;
		
		if (x >= this.m_tx && x <= this.m_tx + this.m_tw
		&&  y >= this.m_ty && y <= this.m_ty + this.m_th) {
			if (this.m_function) this.m_function();
			return 1;
		}
		else {
			
			return 0;
		}
	}
}